<?php 	include("head.php");

		include_once("paging_function.php");

?>

<?php
$today=date("d-m-y");

//echo $today;
/////////////////////////////////PAGING /////////////////

 	if(isset($_GET['page']) && $_GET['page']!='')

		{
			$page = $_GET['page'];
		}
	else
		{
			$page = 0;
		}

$limit=$adminpagelimit;

/////////////////////////////////////////////////////////////////	

?>


<script>
function changeUrl(indexalpha)
{
var url='advisor_satistics.php?index='+indexalpha;
window.location=url;
}
function closeEditWin()
{
document.getElementById('editWin').style.display='none';
}

</script>
<?php
$type=$_POST['selecttype'];
$statustype=$_POST['selectstatus'];

$searchsql_query="SELECT ".SITEUSERS.".siteuserId,".SITEUSERS.".username,".SITEUSERS.".status,".SITEUSERS.".userType,".ADVERTISEMASTER.".advertiseId,".ADVERTISEMASTER.".adTitle,".ADVERTISEMASTER.".startDate,".ADVERTISEMASTER.".dailyBudget,".ADVERTISEMASTER.".maxBudget,".ADVERTISEMASTER.".siteuserId,".ADVDETAILS.".adDetailasId,".ADVDETAILS.".advertiseId,".ADVDETAILS.".adsiteId,".ADVDETAILS.".networkId ,".ADVDETAILS.".adDisplayType,".SITEMASTER.".adsiteId,".SITEMASTER.".siteuserId,".SITEMASTER.".adSiteUrl,".SITEMASTER.".CTR,".NETWORKMASTER.".siteuserId,".NETWORKMASTER.".networkName,".NETWORKMASTER.".networkId,".TRANSACTION.".advertiseId,".TRANSACTION.".dailyBudget,".TRANSACTION.".dailyHit,".TRANSACTION.".costChoice FROM ".SITEUSERS.",".ADVERTISEMASTER.",".ADVDETAILS.",".SITEMASTER.",".TRANSACTION.",".NETWORKMASTER." WHERE ".SITEUSERS.".siteuserId=".ADVERTISEMASTER.".siteuserId AND  ".ADVERTISEMASTER.".advertiseId=".ADVDETAILS.".adDetailasId AND ".SITEMASTER.".adsiteId=".ADVDETAILS.".adsiteId AND ".NETWORKMASTER.".networkId=".ADVDETAILS.".networkId AND ".ADVERTISEMASTER.".advertiseId=".TRANSACTION.".advertiseId AND ".SITEUSERS.".userType ='A'";



$TEMP_hold=0;
	if(isset($_POST['user']) && $_POST['user']!="")

	{
		$param="user=".$_REQUEST['user'];
		$searchsql_query.=" and ".SITEUSERS.".username LIKE '".$_POST['user']."%'";
		$TEMP_hold=1;
	}
	if(isset($_POST['selectstatus']) && $_POST['selectstatus']!="")

	{
		$param="selectstatus=".$_REQUEST['selectstatus'];
		$searchsql_query.=" AND ".SITEUSERS.".status LIKE '".$_POST['selectstatus']."%'";
		$TEMP_hold=1;
	}
	if(isset($_POST['adTitle']) && $_POST['adTitle']!="")

	{
		$param="adTitle=".$_REQUEST['adTitle'];
		$searchsql_query.=" AND ".ADVERTISEMASTER.".adTitle LIKE '".$_POST['adTitle']."%'";
		$TEMP_hold=1;
	}

	if(isset($_POST['adSiteUrl']) && $_POST['adSiteUrl']!="")
	{
		$param="adSiteUrl=".$_REQUEST['adSiteUrl'];
		$searchsql_query.=" AND ".SITEMASTER.".adSiteUrl LIKE '".$_POST['adSiteUrl']."%'";
		$TEMP_hold=1;
	}
	if(isset($_POST['networkName']) && $_POST['networkName']!="")

	{
		$param="networkName=".$_REQUEST['networkName'];
		$searchsql_query.=" AND ".NETWORKMASTER.".networkName LIKE '".$_POST['networkName']."%'";
		$TEMP_hold=1;
	}
	if($_REQUEST['index']!='' && isset($_REQUEST['index']))

	{

		$param="index=".$_REQUEST['index'];
		$searchsql_query.=" AND ".SITEUSERS.".username like'".$_REQUEST['index']."%'";
		$TEMP_hold=1;
	
    	}
	if($TEMP_hold == 0) 
	{
		$searchsql_query.=" ORDER BY ".SITEUSERS.".siteuserId  DESC";

 	}
		$searchsql_query=$searchsql_query." limit $page,$limit";
//echo $searchsql_query;
$searchquery=mysql_query($searchsql_query) or die('<br><br>error1<br><br>'.mysql_error());


	
?>

	  

 <table width="100%" border="0" cellspacing="0" cellpadding="3"  style="border:1px solid #666666">

 <tr><td>&nbsp;</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr>
	<td>

	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="15" colspan="" align="center" style="color:#000000;font-size:12px;"><font color="#000000"><strong>ADVERTISE STATISTICS </strong></font> 
			
		</td>
		<tr>
			<td height="15" colspan="" align="center" style="color:#000000;font-size:12px;">&nbsp; 
			
		</td>
		<tr>	
			<td height="15" colspan="" align="center" style="color:#000000;font-size:12px;"><p><strong style="font-weight: 400">Click on the alphabets to browse User </strong>Name<strong style="font-weight: 400"><br>&nbsp;</strong></p><?php include_once("search_alphabets.php");?></td>
		
		</tr>
	
	</table>
	<br />
	<a href="advisor_satistics.php" style="color:#000000;font-size:12px;">View All</a>
	<br />  
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="tabbod" bgcolor="#F3F3F3">
    <form name="admin_user" action=""  method="post">
    <tr>
	<td colspan="11">
		<table>
			<tr>
				<td class="SMALLHEADING">Search By</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td class="SMALL"> Ad Title:<input type="text"  name="adTitle" size="10" value="<?php echo $_POST['adTitle'];?>" /></td>
				<td class="SMALL">SiteName:<input type="text"  name="adSiteUrl" size="10" value="<?php echo $_POST['adSiteUrl'];?>" /></td>
				<td class="SMALL"> Network Name:<input type="text"  name="networkName" size="10" value="<?php echo $_POST['networkName'];?>" /></td>
				<td class="SMALL"> Username:<input type="text"  name="user" size="10" value="<?php echo $_POST['user'];?>" /></td>					
				<td class="SMALL"> User Status:<select name="selectstatus" class="SMALL" >
						<option value="" selected="selected">User Status </option>
						<option value="Y"<?php if($_POST['selectstatus'] == "Y") echo 'selected'; ?>>Active</option>
						<option value="N"<?php if($_POST['selectstatus'] == "N") echo 'selected'; ?>>Inactive</option>
						<option value="P"<?php if($_POST['selectstatus'] == "P") echo 'selected'; ?>>Pending</option>
						<option value="B"<?php if($_POST['selectstatus'] == "B") echo 'selected'; ?>>Block</option>
					    </select>
				</td>
				<td><input type="submit" name="search" value="Search" /></td>
			</tr>
		</table>
	</td>
    </tr></form>

    <?php

  if(mysql_num_rows($searchquery)>0)

  {
  ?><form name="form_admin_management" action="" method="post">

	<tr bgcolor="#6F8DBC">
	
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>S.No</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>AdTitle</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>SiteName</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>NetworkName</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>User Name </strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>RunDates</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Amount</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Cost</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Impression/Clicks</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Todaysclick(CPC)/<br>Impression(CPM)</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Status</strong></td>

	</tr>


    <?php 

  $count=0;
  $sno=1;
  $loop=0;
  while($searcharray=mysql_fetch_array($searchquery))
	{
	
			$loop++;
			if($loop == 1)
			$bgcolor = "#F0F0FF";
			else 
			$bgcolor = "#CCCCFF";
	
	?>
	
	<tr bgcolor="<?php echo $bgcolor; ?>">

		<td  style="color:#000000;font-size:10px;border-right:1px solid #FFFFFF;"><strong><?php echo $sno+$_GET['page'];?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong><?php echo $searcharray['adTitle']; ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong><?php echo $searcharray['adSiteUrl']; ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong><?php echo $searcharray['networkName']; ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong><?php echo $searcharray['username']; ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong><?php echo $date=substr($searcharray['startDate'],0,10); ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>$&nbsp;<?php echo $searcharray['maxBudget']; ?></strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>$&nbsp;<?php echo $searcharray['dailyBudget']; ?></strong></td>	
		<td  style="color:#000000;font-size:10px;border-right:1px solid #FFFFFF;" align="center"><strong><?php  echo $searcharray['CTR']; ?></strong></td>
		<td  style="color:#000000;font-size:10px;border-right:1px solid #FFFFFF;" align="center"><strong><?php   echo $searcharray['dailyHit']; ?></strong></td>	
		<td  style="color:#000000;font-size:10px;border-right:1px solid #FFFFFF;"><strong><?php 														if($searcharray['status']=='Y')
								{
									echo "Active";
								}
							if($searcharray['status']=='N')
								{
									echo "In Active";
								}
							if($searcharray['status']=='P')
								{
									echo "Pending";
								}
							if($searcharray['status']=='B')
								{
									echo "Blocked";
								}
								
								?></strong>
		</td>

	</tr>
	
<?php	
	  $count++;
  $sno++;
 		 if($loop == 2)
			{
			$loop = 0;
			}	
		 
	}?>
	
	<tr>
		<td colspan="11">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="11" align="center" style="color:#FF0000"><?php echo paging($searchsql_query,$page,$limit,'',$param);?></td>
	</tr>

    <?php
	}
else
	{
?>
	
	<tr bgcolor="#6F8DBC">
	
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>S.No</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>AdName</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>SiteName</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>NetworkName</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>User Name </strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>RunDates</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Amount</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Cost</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Impression/Clicks</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Todaysclick(CPC)/<br>Impression(CPM)</strong></td>
		<td  style="color:#000000;font-size:11px;border-right:1px solid #FFFFFF;"><strong>Status</strong></td>
	</tr>
		<td colspan="11" align="center" valign="middle" height="96"><strong><font color="#FF0000">No data available!</font></strong></td>
	</tr>
<?php  } ?>
</form>
	
</table>
	
	</td>
</tr>
</table>

<?php include("foot.php");?>
